---------------------------------------------------------------------------------------------------------------------- -- Менеджер изменения состояния тела -- автор: Диденко Руслан (Stohe) -- перехерячивал: Пличко Александр (Plecha) -- TODO: ---------------------------------------------------------------------------------------------------------------------- properties = {} operators = {} -- MANAGER properties["end"] = 1 properties["locked"] = 2 properties["locked_external"] = 3 -- WEAPON properties["weapon"] = 11 properties["weapon_locked"] = 12 properties["weapon_strapped"] = 13 properties["weapon_strapped_now"] = 14 properties["weapon_unstrapped"] = 15 properties["weapon_unstrapped_now"] = 16 properties["weapon_none"] = 17 properties["weapon_none_now"] = 18 properties["weapon_drop"] = 19 properties["weapon_fire"] = 20 -- MOVEMENT properties["movement"] = 21 properties["movement_walk"] = 22 properties["movement_run"] = 23 properties["movement_stand"] = 24 properties["movement_stand_now"] = 25 -- MENTAL STATES properties["mental"] = 31 properties["mental_free"] = 32 properties["mental_free_now"] = 33 properties["mental_danger"] = 34 properties["mental_danger_now"] = 35 properties["mental_panic"] = 36 properties["mental_panic_now"] = 37 -- BODYSTATES properties["bodystate"] = 41 properties["bodystate_crouch"] = 42 properties["bodystate_standing"] = 43 properties["bodystate_crouch_now"] = 44 properties["bodystate_standing_now"] = 45 -- DIRECTION properties["direction"] = 51 properties["direction_search"] = 52 -- ANIMSTATE properties["animstate"] = 61 properties["animstate_locked"] = 62 properties["animstate_idle_now"] = 64 properties["animstate_play_now"] = 66 -- ANIMATION properties["animation"] = 81 properties["animation_locked"] = 82 properties["animation_play_now"] = 84 properties["animation_none_now"] = 86 -- SMARTCOVER properties["smartcover_need"] = 90 properties["smartcover"] = 91 properties["in_smartcover"] = 92 -- properties["smartcover_locked"] = 92 operators["end"] = 1 operators["locked"] = 2 operators["locked_external"] = 3 operators["locked_animation"] = 4 operators["locked_animstate"] = 5 operators["locked_smartcover"] = 6 operators["weapon_strapp"] = 11 operators["weapon_unstrapp"] = 12 operators["weapon_none"] = 13 operators["weapon_fire"] = 14 operators["weapon_drop"] = 15 operators["movement"] = 21 operators["movement_walk"] = 22 operators["movement_run"] = 23 operators["movement_stand"] = 24 operators["movement_walk_turn"] = 25 operators["movement_walk_search"] = 26 operators["movement_stand_turn"] = 27 operators["movement_stand_search"] = 28 operators["movement_run_turn"] = 29 operators["movement_run_search"] = 30 operators["mental_free"] = 31 operators["mental_danger"] = 32 operators["mental_panic"] = 33 operators["bodystate_crouch"] = 41 operators["bodystate_standing"] = 42 operators["bodystate_crouch_danger"] = 43 operators["bodystate_standing_free"] = 44 operators["direction_turn"] = 51 operators["direction_search"] = 52 operators["animstate_start"] = 61 operators["animstate_stop"] = 62 operators["animation_start"] = 71 operators["animation_stop"] = 72 operators["walk_turn"] = 75 operators["walk_search"] = 76 operators["stand_turn"] = 77 operators["stand_search"] = 78 operators["smartcover_enter"] = 80 operators["smartcover_exit"] = 81 --' Сам менеджер function goap_graph(st, npc) st.npc = npc st.planner = action_planner() st.planner:setup(npc) -- EVALUATORS st.planner:add_evaluator(properties["end"], state_mgr.eva_state_mgr_end("state_mgr_end", st)) st.planner:add_evaluator(properties["locked"], state_mgr.eva_state_mgr_locked("state_mgr_locked", st)) st.planner:add_evaluator(properties["locked_external"], state_mgr.eva_state_mgr_locked_external("state_mgr_locked_external", st)) st.planner:add_evaluator(properties["weapon"], state_mgr_weapon.eva_state_mgr_weapon("state_mgr_weapon", st)) st.planner:add_evaluator(properties["weapon_locked"], state_mgr_weapon.eva_state_mgr_weapon_locked("state_mgr_weapon_locked", st)) st.planner:add_evaluator(properties["weapon_strapped"], state_mgr_weapon.eva_state_mgr_weapon_strapped("state_mgr_weapon_strapped", st)) st.planner:add_evaluator(properties["weapon_strapped_now"], state_mgr_weapon.eva_state_mgr_weapon_strapped_now("state_mgr_weapon_strapped_now", st)) st.planner:add_evaluator(properties["weapon_unstrapped"], state_mgr_weapon.eva_state_mgr_weapon_unstrapped("state_mgr_weapon_unstrapped", st)) st.planner:add_evaluator(properties["weapon_unstrapped_now"], state_mgr_weapon.eva_state_mgr_weapon_unstrapped_now("state_mgr_weapon_unstrapped_now", st)) st.planner:add_evaluator(properties["weapon_none"], state_mgr_weapon.eva_state_mgr_weapon_none("state_mgr_weapon_none", st)) st.planner:add_evaluator(properties["weapon_none_now"], state_mgr_weapon.eva_state_mgr_weapon_none_now("state_mgr_weapon_none_now", st)) st.planner:add_evaluator(properties["weapon_drop"], state_mgr_weapon.eva_state_mgr_weapon_drop("state_mgr_weapon_drop", st)) st.planner:add_evaluator(properties["weapon_fire"], state_mgr_weapon.eva_state_mgr_weapon_fire("state_mgr_weapon_fire", st)) st.planner:add_evaluator(properties["movement"], state_mgr_movement.eva_state_mgr_movement("state_mgr_movement", st)) st.planner:add_evaluator(properties["movement_walk"], state_mgr_movement.eva_state_mgr_movement_walk("state_mgr_movement_walk", st)) st.planner:add_evaluator(properties["movement_run"], state_mgr_movement.eva_state_mgr_movement_run("state_mgr_movement_run", st)) st.planner:add_evaluator(properties["movement_stand"], state_mgr_movement.eva_state_mgr_movement_stand("state_mgr_movement_stand", st)) st.planner:add_evaluator(properties["movement_stand_now"], state_mgr_movement.eva_state_mgr_movement_stand_now("state_mgr_movement_stand_now", st)) st.planner:add_evaluator(properties["mental"], state_mgr_mental.eva_state_mgr_mental("state_mgr_mental", st)) st.planner:add_evaluator(properties["mental_free"], state_mgr_mental.eva_state_mgr_mental_free("state_mgr_mental_free", st)) st.planner:add_evaluator(properties["mental_free_now"], state_mgr_mental.eva_state_mgr_mental_free_now("state_mgr_mental_free_now", st)) st.planner:add_evaluator(properties["mental_danger"], state_mgr_mental.eva_state_mgr_mental_danger("state_mgr_mental_danger", st)) st.planner:add_evaluator(properties["mental_danger_now"], state_mgr_mental.eva_state_mgr_mental_danger_now("state_mgr_mental_danger_now", st)) st.planner:add_evaluator(properties["mental_panic"], state_mgr_mental.eva_state_mgr_mental_panic("state_mgr_mental_panic", st)) st.planner:add_evaluator(properties["mental_panic_now"], state_mgr_mental.eva_state_mgr_mental_panic_now("state_mgr_mental_panic_now", st)) st.planner:add_evaluator(properties["bodystate"], state_mgr_bodystate.eva_state_mgr_bodystate("state_mgr_bodystate", st)) st.planner:add_evaluator(properties["bodystate_crouch"], state_mgr_bodystate.eva_state_mgr_bodystate_crouch("state_mgr_bodystate_crouch", st)) st.planner:add_evaluator(properties["bodystate_standing"], state_mgr_bodystate.eva_state_mgr_bodystate_standing("state_mgr_bodystate_standing", st)) st.planner:add_evaluator(properties["bodystate_crouch_now"], state_mgr_bodystate.eva_state_mgr_bodystate_crouch_now("state_mgr_bodystate_crouch_now", st)) st.planner:add_evaluator(properties["bodystate_standing_now"], state_mgr_bodystate.eva_state_mgr_bodystate_standing_now("state_mgr_bodystate_standing_now", st)) st.planner:add_evaluator(properties["direction"], state_mgr_direction.eva_state_mgr_direction("state_mgr_direction", st)) st.planner:add_evaluator(properties["direction_search"], state_mgr_direction.eva_state_mgr_direction_search("state_mgr_direction_search", st)) st.animstate = state_mgr_animation.animation(npc, st, "state_mgr_animstate_list") st.planner:add_evaluator(properties["animstate"], state_mgr_animstate.eva_state_mgr_animstate("state_mgr_animstate", st)) st.planner:add_evaluator(properties["animstate_idle_now"], state_mgr_animstate.eva_state_mgr_animstate_idle_now("state_mgr_animstate_idle_now", st)) st.planner:add_evaluator(properties["animstate_play_now"], state_mgr_animstate.eva_state_mgr_animstate_play_now("state_mgr_animstate_play_now", st)) st.planner:add_evaluator(properties["animstate_locked"], state_mgr_animstate.eva_state_mgr_animstate_locked("state_mgr_animstate_locked", st)) st.animation = state_mgr_animation.animation(npc, st, "state_mgr_animation_list") st.npc:set_callback(callback.script_animation , st.animation.anim_callback, st.animation) st.planner:add_evaluator(properties["animation"], state_mgr_animation.eva_state_mgr_animation("state_mgr_animation", st)) st.planner:add_evaluator(properties["animation_play_now"], state_mgr_animation.eva_state_mgr_animation_play_now("state_mgr_animation_play_now", st)) st.planner:add_evaluator(properties["animation_none_now"], state_mgr_animation.eva_state_mgr_animation_none_now("state_mgr_animation_none_now", st)) st.planner:add_evaluator(properties["animation_locked"], state_mgr_animation.eva_state_mgr_animation_locked("state_mgr_animation_locked", st)) st.planner:add_evaluator(properties["smartcover"], state_mgr_smartcover.eva_state_mgr_smartcover("state_mgr_smartcover", st)) st.planner:add_evaluator(properties["smartcover_need"], state_mgr_smartcover.eva_state_mgr_smartcover_need("state_mgr_smartcover_need", st)) st.planner:add_evaluator(properties["in_smartcover"], state_mgr_smartcover.eva_state_mgr_in_smartcover("state_mgr_in_smartcover", st)) -- st.planner:add_evaluator(properties["smartcover_locked"], state_mgr_smartcover.eva_state_mgr_smartcover_locked("state_mgr_smartcover_locked", st)) --' Actions --************************************************************************************ --* SMART_ACTIONS * --************************************************************************************ -- WEAPON -- UNSTRAPP local wp = world_property local action = state_mgr_weapon.act_state_mgr_weapon_unstrapp("state_mgr_weapon_unstrapp", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_precondition (wp(properties["weapon_unstrapped"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["weapon"], true)) st.planner:add_action(operators["weapon_unstrapp"], action) end -- STRAPP action = state_mgr_weapon.act_state_mgr_weapon_strapp("state_mgr_weapon_strapp", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_precondition (wp(properties["weapon_strapped"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["weapon"], true)) st.planner:add_action(operators["weapon_strapp"], action) end -- NONE action = state_mgr_weapon.act_state_mgr_weapon_none("state_mgr_weapon_none", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_precondition (wp(properties["weapon_none"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["weapon"], true)) st.planner:add_action(operators["weapon_none"], action) end -- DROP action = state_mgr_weapon.act_state_mgr_weapon_drop("state_mgr_weapon_drop", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_precondition (wp(properties["weapon_drop"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["weapon"], true)) st.planner:add_action(operators["weapon_drop"], action) end -- MOVEMENT -- WALK action = state_mgr_movement.act_state_mgr_movement_walk("state_mgr_movement_walk", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], false)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) -- action:add_precondition (wp(properties["weapon"], true)) -- action:add_precondition (wp(properties["direction"], true)) -- TEST ? action:add_precondition (wp(properties["movement_walk"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["movement"], true)) st.planner:add_action(operators["movement_walk"], action) end -- WALK_turn action = state_mgr_movement.act_state_mgr_movement_walk_turn("state_mgr_movement_walk_turn", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], false)) action:add_precondition (wp(properties["direction"], false)) action:add_precondition (wp(properties["direction_search"], false)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) -- action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["movement_walk"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["movement"], true)) action:add_effect (wp(properties["direction"], true)) st.planner:add_action(operators["movement_walk_turn"], action) end -- WALK_search action = state_mgr_movement.act_state_mgr_movement_walk_search("state_mgr_movement_walk_search", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], false)) action:add_precondition (wp(properties["direction"], false)) action:add_precondition (wp(properties["direction_search"], true)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) -- action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["movement_walk"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["movement"], true)) action:add_effect (wp(properties["direction"], true)) st.planner:add_action(operators["movement_walk_search"], action) end -- RUN action = state_mgr_movement.act_state_mgr_movement_run("state_mgr_movement_run", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], false)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) -- action:add_precondition (wp(properties["direction"], true)) -- TEST ? -- action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["movement_run"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["movement"], true)) st.planner:add_action(operators["movement_run"], action) end -- RUN_turn action = state_mgr_movement.act_state_mgr_movement_run("state_mgr_movement_run_turn", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], false)) action:add_precondition (wp(properties["direction"], false)) action:add_precondition (wp(properties["direction_search"], false)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) -- action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["movement_run"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["movement"], true)) action:add_effect (wp(properties["direction"], true)) st.planner:add_action(operators["movement_run_turn"], action) end -- RUN_search action = state_mgr_movement.act_state_mgr_movement_run("state_mgr_movement_run_search", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["movement"], false)) action:add_precondition (wp(properties["direction"], false)) action:add_precondition (wp(properties["direction_search"], true)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["mental"], true)) -- action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["movement_run"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_effect (wp(properties["movement"], true)) action:add_effect (wp(properties["direction"], true)) st.planner:add_action(operators["movement_run_search"], action) end -- STAND action = state_mgr_movement.act_state_mgr_movement_stand("state_mgr_movement_stand", st) if action then action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["movement"], false)) action:add_precondition (wp(properties["movement_stand"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_effect (wp(properties["movement"], true)) st.planner:add_action(operators["movement_stand"], action) end -- STAND_turn action = state_mgr_movement.act_state_mgr_movement_stand_turn("state_mgr_movement_stand_turn", st) if action then action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["movement"], false)) action:add_precondition (wp(properties["direction"], false)) action:add_precondition (wp(properties["direction_search"], false)) action:add_precondition (wp(properties["movement_stand"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_effect (wp(properties["movement"], true)) action:add_effect (wp(properties["direction"], true)) st.planner:add_action(operators["movement_stand_turn"], action) end -- STAND_search action = state_mgr_movement.act_state_mgr_movement_stand_search("state_mgr_movement_stand_search", st) if action then action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["movement"], false)) action:add_precondition (wp(properties["direction"], false)) action:add_precondition (wp(properties["direction_search"], true)) action:add_precondition (wp(properties["movement_stand"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_effect (wp(properties["movement"], true)) action:add_effect (wp(properties["direction"], true)) st.planner:add_action(operators["movement_stand_search"], action) end -- DIRECTION -- TURN action = state_mgr_direction.act_state_mgr_direction_turn("state_mgr_direction_turn", st) if action then --action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["direction"], false)) action:add_precondition (wp(properties["direction_search"], false)) action:add_precondition (wp(properties["weapon"], true))--! action:add_precondition (wp(properties["animation_none_now"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["movement"], true)) action:add_effect (wp(properties["direction"], true)) st.planner:add_action(operators["direction_turn"], action) end -- SEARCH action = state_mgr_direction.act_state_mgr_direction_search("state_mgr_direction_search", st) if action then --action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["direction"], false)) action:add_precondition (wp(properties["direction_search"], true)) action:add_precondition (wp(properties["weapon"], true))--! action:add_precondition (wp(properties["animation_none_now"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["movement"], true)) action:add_effect (wp(properties["direction"], true)) st.planner:add_action(operators["direction_search"], action) end -- MENTAL STATES -- FREE action = state_mgr_mental.act_state_mgr_mental_free("state_mgr_mental_free") if action then action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["mental"], false)) -- action:add_precondition (wp(properties["weapon"], true)) --' action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_precondition (wp(properties["mental_free"], true)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["bodystate_standing_now"], true)) action:add_effect (wp(properties["mental"], true)) st.planner:add_action(operators["mental_free"], action) end -- DANGER action = state_mgr_mental.act_state_mgr_mental_danger("state_mgr_mental_danger") if action then action:add_precondition (wp(properties["mental"], false)) action:add_precondition (wp(properties["locked_external"], false)) -- action:add_precondition (wp(properties["weapon"], true)) --' action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_precondition (wp(properties["mental_danger"], true)) action:add_effect (wp(properties["mental"], true)) action:add_effect (wp(properties["mental_danger_now"], true)) st.planner:add_action(operators["mental_danger"], action) end -- PANIC action = state_mgr_mental.act_state_mgr_mental_panic("state_mgr_mental_panic") if action then action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["mental"], false)) -- action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_precondition (wp(properties["mental_panic"], true)) action:add_effect (wp(properties["mental"], true)) st.planner:add_action(operators["mental_panic"], action) end -- BODYSTATES -- CROUCH action = state_mgr_bodystate.act_state_mgr_bodystate_crouch("state_mgr_bodystate_crouch") if action then action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["bodystate"], false)) -- action:add_precondition (wp(properties["weapon"], true)) --' action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["bodystate_crouch_now"], false)) action:add_precondition (wp(properties["bodystate_crouch"], true)) action:add_precondition (wp(properties["mental_danger_now"], true)) action:add_effect (wp(properties["bodystate"], true)) st.planner:add_action(operators["bodystate_crouch"], action) end -- CROUCH_danger action = state_mgr_bodystate.act_state_mgr_bodystate_crouch_danger("state_mgr_bodystate_crouch_danger") if action then action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["bodystate"], false)) action:add_precondition (wp(properties["mental"], false)) -- action:add_precondition (wp(properties["weapon"], true)) --' action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["bodystate_crouch_now"], false)) action:add_precondition (wp(properties["bodystate_crouch"], true)) action:add_effect (wp(properties["bodystate"], true)) action:add_effect (wp(properties["mental"], true)) st.planner:add_action(operators["bodystate_crouch_danger"], action) end -- STAND action = state_mgr_bodystate.act_state_mgr_bodystate_standing("state_mgr_bodystate_standing", st) if action then action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["bodystate"], false)) -- action:add_precondition (wp(properties["weapon"], true)) --' action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["bodystate_standing_now"], false)) action:add_precondition (wp(properties["bodystate_standing"], true)) action:add_effect (wp(properties["bodystate"], true)) action:add_effect (wp(properties["bodystate_standing_now"], true)) st.planner:add_action(operators["bodystate_standing"], action) end -- STAND_free action = state_mgr_bodystate.act_state_mgr_bodystate_standing_free("state_mgr_bodystate_standing_free", st) if action then action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["bodystate"], false)) action:add_precondition (wp(properties["mental"], false)) -- action:add_precondition (wp(properties["weapon"], true)) --' action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["bodystate_standing_now"], false)) action:add_precondition (wp(properties["bodystate_standing"], true)) action:add_precondition (wp(properties["mental_free"], false)) action:add_effect (wp(properties["bodystate"], true)) action:add_effect (wp(properties["bodystate_standing_now"], true)) action:add_effect (wp(properties["mental"], true)) st.planner:add_action(operators["bodystate_standing_free"], action) end -- ANIMSTATES action = state_mgr_animstate.act_state_mgr_animstate_start("state_mgr_animstate_start", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["animstate"], false)) action:add_precondition (wp(properties["smartcover"], true)) action:add_precondition (wp(properties["animation_none_now"], true)) action:add_precondition (wp(properties["direction"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["animstate_play_now"], false)) action:add_effect (wp(properties["animstate"], true)) st.planner:add_action(operators["animstate_start"], action) end action = state_mgr_animstate.act_state_mgr_animstate_stop("state_mgr_animstate_stop", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["animation_locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false))--! --action:add_precondition (wp(properties["animstate"], false)) action:add_precondition (wp(properties["animstate_idle_now"], false)) action:add_precondition (wp(properties["animation_play_now"], false)) action:add_effect (wp(properties["animstate"], true)) action:add_effect (wp(properties["animstate_play_now"], false)) action:add_effect (wp(properties["animstate_idle_now"], true)) st.planner:add_action(operators["animstate_stop"], action) end -- ANIMATION -- START action = state_mgr_animation.act_state_mgr_animation_start("state_mgr_animation_start", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["animstate_locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) action:add_precondition (wp(properties["animstate"], true)) action:add_precondition (wp(properties["smartcover"], true)) action:add_precondition (wp(properties["in_smartcover"], false)) action:add_precondition (wp(properties["direction"], true)) action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["animation"], false)) action:add_precondition (wp(properties["animation_play_now"], false)) action:add_effect (wp(properties["animation"], true)) st.planner:add_action(operators["animation_start"], action) end -- STOP action = state_mgr_animation.act_state_mgr_animation_stop("state_mgr_animation_stop", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["locked_external"], false)) --action:add_precondition (wp(properties["animstate"], true)) --action:add_precondition (wp(properties["animation"], false)) action:add_precondition (wp(properties["animation_play_now"], true)) action:add_effect (wp(properties["animation"], true)) action:add_effect (wp(properties["animation_play_now"], false)) action:add_effect (wp(properties["animation_none_now"], true)) st.planner:add_action(operators["animation_stop"], action) end -- SMARTCOVER - вход action = state_mgr_smartcover.act_state_mgr_smartcover_enter("act_state_mgr_smartcover_enter", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["smartcover_need"], true)) action:add_precondition (wp(properties["smartcover"], false)) action:add_precondition (wp(properties["animstate_idle_now"], true)) action:add_precondition (wp(properties["animation_play_now"], false)) action:add_effect (wp(properties["smartcover"], true)) st.planner:add_action(operators["smartcover_enter"], action) end -- SMARTCOVER - выход action = state_mgr_smartcover.act_state_mgr_smartcover_exit("act_state_mgr_smartcover_exit", st) if action then action:add_precondition (wp(properties["locked"], false)) action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["smartcover_need"], false)) action:add_precondition (wp(properties["smartcover"], false)) action:add_effect (wp(properties["smartcover"], true)) st.planner:add_action(operators["smartcover_exit"], action) end action = state_mgr.act_state_mgr_locked("state_mgr_locked_smartcover", st) if action then action:add_precondition (wp(properties["in_smartcover"], true)) action:add_effect (wp(properties["in_smartcover"], false)) st.planner:add_action(operators["locked_smartcover"], action) end -- LOCKED action = state_mgr.act_state_mgr_locked("state_mgr_locked", st) if action then action:add_precondition (wp(properties["locked"], true)) action:add_effect (wp(properties["locked"],false)) st.planner:add_action(operators["locked"], action) end action = state_mgr.act_state_mgr_locked("state_mgr_locked_animation", st) if action then action:add_precondition (wp(properties["animation_locked"], true)) action:add_effect (wp(properties["animation_locked"],false)) st.planner:add_action(operators["locked_animation"], action) end action = state_mgr.act_state_mgr_locked("state_mgr_locked_animstate", st) if action then action:add_precondition (wp(properties["animstate_locked"], true)) action:add_effect (wp(properties["animstate_locked"],false)) st.planner:add_action(operators["locked_animstate"], action) end action = state_mgr.act_state_mgr_locked("state_mgr_locked_external", st) if action then action:add_precondition (wp(properties["locked_external"], true)) action:add_effect (wp(properties["locked_external"],false)) st.planner:add_action(operators["locked_external"], action) end -- END action = state_mgr.act_state_mgr_end("state_mgr_end", st) if action then action:add_precondition (wp(properties["end"], false)) action:add_precondition (wp(properties["weapon"], true)) action:add_precondition (wp(properties["movement"], true)) action:add_precondition (wp(properties["mental"], true)) action:add_precondition (wp(properties["bodystate"], true)) action:add_precondition (wp(properties["direction"], true)) action:add_precondition (wp(properties["animstate"], true)) action:add_precondition (wp(properties["animation"], true)) action:add_precondition (wp(properties["smartcover"], true)) action:add_effect (wp(properties["end"], true)) st.planner:add_action(operators["end"], action) end local goal = world_state() goal:add_property(wp(properties["end"],true)) st.planner:set_goal_world_state(goal) --if npc.debug_planner ~= nil then --npc:debug_planner(st.planner) --end end